<?php
class Server {
  public static function delete_obj($orm) {
    $req = json_decode(Utils::get_param('req', '[]'));
    
    $opts = new stdClass();
    $opts->cd = '`sys_id` = :v1';
    $opts->cdv = array(':v1' => $req->id);
    $orm->delete_by_opts('pb_plugin_instance', $opts);
    
    $opts = new stdClass();
    $opts->cd = 'sys_id = :v1';
    $opts->cdv = array(':v1' => $req->id);
    $orm->delete_by_opts('pb_page', $opts);
    
    if (file_exists('../' . HOME_DIR . '/' . $req->php_name . '.php')) {
      unlink('../' . HOME_DIR . '/' . $req->php_name . '.php');
    }
    
    $orm->delete('pb_sys', $req);
    
    include '__clear.php';
    echo json_encode($req);
  }
}
?>
